/**
 * 
 */

	var req;
	function validate() {
		var emailField = document.getElementById("email");
		var url = "Validate.jsp?email=" + escape(emailField.value);
		alert(url);
		if(window.XMLHttpRequest) {
			req = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
		}
		req.open("GET", url, true);
		req.onreadystatechange = callback;
		req.send(null);
	}
	function callback() {
		if(req.readyState == 4) {
			if(req.status == 200) {
				//alert(req.responseText);
				var msg = req.responseXML.getElementsByTagName("msg")[0];
				var table=req.responseXML.getElementsByTagName("table")[0];
				//alert(msg);
		        setMsg(msg.childNodes[0].nodeValue);
			}
		}
	}
	
	function setMsg(msg) {	
		alert("Fuck you");
		mdiv = document.getElementById("customerMsg");
		if(msg == "invalid") {
			mdiv.innerHTML = "<font color='red'>Customer doesn't exist</font>";
		} else {
			mdiv.innerHTML = "<font color='green'>Valid</font>";
		}
	}
